import os
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    # 定义参数文件的路径
    param_file_path = os.path.join(
        os.path.expanduser('~'),
        'launch',
        'custom_param.yaml'
    )
    
    # 获取当前脚本所在的目录
    #current_dir = os.path.dirname(os.path.abspath(__file__))

    # 构建参数文件的完整路径
    #param_file_path = os.path.join(current_dir, 'custom_params.yaml')

    # 打印参数文件的完整路径
    print(f"参数文件的完整路径是: {param_file_path}")

    # 创建mavros_node节点
    mavros_node = Node(
        package='mavros',
        executable='mavros_node',
        parameters=[param_file_path],
        output='screen'
    )

    # 创建LaunchDescription对象
    ld = LaunchDescription()

    # 添加节点到LaunchDescription
    ld.add_action(mavros_node)

    return ld

